package com.ddy.test.boxiao;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ddy.test.inputStream.FileReader;
import com.google.gson.JsonDeserializer;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by ddy on 2017/12/14.
 */
public class TeachAttendanceConvert {

    public static void main(String[] args) {
        long startTime=1514514000000L,endTime=1514516700000L;
        System.out.println("startTime= " + new Date(startTime) +" &endTime=" + new Date(endTime));
        String jsonFile = "/Users/ddy/logs/tea.json";
        String jsonString = FileReader.readStringFromTxt(jsonFile);
        Map<String,List> map = JSON.parseObject(jsonString, Map.class);
        for(String userId : map.keySet()){
            List<Map<String,Long>> list = map.get(userId);
            System.out.println("===========================" + userId);
            for(Map<String,Long> timeMap :list){
                long inTime = timeMap.get("inTime");
                long outTime = timeMap.get("outTime");
                System.out.println("inTime " + new Date(inTime) +"==> outTime " + new Date(outTime));
            }
        }

    }

    public static void convert(String jsonString){
        JSONObject object = JSONObject.parseObject(jsonString);
        Map<String,List> map = (Map<String, List>) object.get("data");
        for(String userId : map.keySet()){
            List<Map<String,Long>> list = map.get(userId);
            System.out.println("===========================" + userId);
            for(Map<String,Long> timeMap :list){
                long inTime = timeMap.get("inTime");
                long outTime = timeMap.get("outTime");
                System.out.println("inTime " + new Date(inTime) +"==> outTime " + new Date(outTime));
            }
        }
    }

}
